package org.itheima.controller;

import org.itheima.pojo.UserSearchHistory;
import org.itheima.service.UserSearchHistoryService;
import org.itheima.utils.ThreadLocalUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/userSearchHistory")
public class UserSearchHistoryController {

    @Autowired
    private UserSearchHistoryService userSearchHistoryService;

    @GetMapping("/findById")
    public List<Map<String,Object>> findById(){
        Map<String,Object> map = ThreadLocalUtil.get();
        int user_id = (int) map.get("id");
        return  userSearchHistoryService.findById(user_id);
    }

}
